<?php
	$col = 4;
	$row = ceil(count($products)/$col);
?>
	<div class="product-box">
            <h3>
                <a href="<?php echo Router::url(array('controller' => 'products', 'action' => 'index')); ?>"><?php echo __('Sản phẩm', true); ?></a> 
                <?php if (isset($cat_name)) : ?>
                &RightTriangle; <?php echo $cat_name; ?>
                <?php endif; ?>
                <?php if (isset($cat_name2)) : ?>
                &RightTriangle; <?php echo $cat_name2; ?>
                <?php endif; ?>
            </h3>
	<?php
            echo $session->flash();
	?>
	<?php for($m =0; $m < $row; $m++) : ?>
	<ul class="thumbnails">
	<?php for($n =0; $n<  $col; $n++) : ?>
		<?php
			if(isset($products[$m * $col + $n])) :
				$item = $products[$m * $col + $n];
				$img = (empty($item['Product']['img'])? "no_image.gif" : $item['Product']['img'] );
		?>
		<li class="span3">
			<div class="thumbnail">
			  <?php
				echo $html->link(
					$html->image(
						IMG_URL ."products/{$img}",
						array(
							'alt'		=> $item['Product']['name_'.$lang],
							'class'		=> 'productImg',
							'height'	=> '112px'
						)
					),
					IMG_URL .'products/'.  $img,
					array(
						'title'			=> $item['Product']['name_'.$lang],
						'rel'			=> 'nofollow',
						'escape'		=> false,
						'class'			=> 'preview'
					)
				);
			  ?>
			  <div class="caption">
				<h4><a href="<?php echo Router::url(array('controller'=> 'product','action' => 'detail',$item['Product']['id'])); ?>"><?php echo $item['Product']['name_'.$lang]?></a></h4>
				<p>ĐVT: <?php echo $item['Product']['unit']; ?></p>
				<p>
                                    <?php if (!isset($vipDiscount)) : ?>
                                            <span class="price-new"><?php echo number_format($item['Product']['price'],0,' ','.')?> VNĐ</span>					
                                          <?php else : ?>
                                            <span class="price-old"><?php echo number_format($item['Product']['price'],0,' ','.')?> VNĐ</span>
                                            <span class="price-new"><?php echo number_format($item['Product']['price'] * (100 - $vipDiscount) / 100,0,' ','.') ; ?> VNĐ</span>
                                    <?php endif; ?>
                                </p>
                                <div class="row-fluid">
                                    <span class="pull-right">
                                        <?php
                                            if ($item['Product']['type'] == 1) {
                                                    echo "<strong style='color:#333'>".__('Contact', true)."</strong>";
                                            }
                                            else {
                                                    if ($item['Product']['isOutStock'] == 0) {
                                            ?>
                                                    <a href="<?php echo Router::url(array('controller' => 'product','action' => 'order',$item['Product']['id'],'index'));?>" class="btn btn-mini btn-danger">Đặt hàng</a></span>
                                            <?php
                                                    }
                                            }
                                    ?> 
                                    </span>
                                </div>
			  </div>
			</div>
		</li>
		<?php endif; ?>
	<?php endfor; ?>
</ul>
<?php endfor; ?>
<?php echo $this->element('layouts/page_nav'); ?>

